package com.szqhyxj.youxiangju.biz.merchantHome.shop.pay;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.TextView;

import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.merchantHome.MerchantContainerActivity;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PaySuccessfulActivity extends AppCompatActivity implements NavigationBar.NavigationBarListener{
    public static final String CONTENT = "content";
    public static final String INTENT_TYPE = "PaySuccessfulActivity";
    public static final String TITILETYPE ="titletype";
    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.content)
    TextView content;
    @BindView(R.id.achieve)
    Button achieve;

    int titletype;
    public static void start(Activity activity, String msg,int titletype){
        Intent intent = new Intent();
        intent.putExtra(CONTENT, msg);
        intent.setClass(activity, PaySuccessfulActivity.class);
        intent.putExtra(TITILETYPE,titletype);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_successful);
        ButterKnife.bind(this);
        navigationBar.setNavigationBarListener(this);
        Intent intent = getIntent();
        String stContent = intent.getStringExtra(CONTENT);
        content.setText(stContent);
        titletype = getIntent().getIntExtra(TITILETYPE,0);
        if (titletype==1){
            navigationBar.setNaviTitle("平台购机");
        }else if (titletype==2){
            navigationBar.setNaviTitle("优享钜合伙人");
        }else{
            navigationBar.setNaviTitle("平台购机");
        }
    }

    @OnClick(R.id.achieve)
    public void onViewClicked(){
        MerchantContainerActivity.start(this,true);
    }

    @Override
    public void navigationLeft(){
        MerchantContainerActivity.start(this,true);
    }

    @Override
    public void navigationRight(){
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event){
        if(keyCode==KeyEvent.KEYCODE_BACK){
            MerchantContainerActivity.start(this,true);
        }
        return super.onKeyDown(keyCode, event);
    }
}
